package com.ajhlp.db.jdo;

import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;

import com.ajhlp.basic.model.BookMark;

public class BookMarkDaoImpl extends BasicPersistDaoImpl {

	@SuppressWarnings("unchecked")
	public List<BookMark> searchBookMarks(String name, String tag){
		PersistenceManager pm = PMF.get().getPersistenceManager();
		try {
			
			Query query = pm.newQuery(BookMark.class);
			query.setFilter("name == :nameparam && tags == :tagparam");
			query.setOrdering("name asc");
			
			List<BookMark> marks = (List<BookMark>) query.execute(name,tag);
			
			if(marks != null && !marks.isEmpty()){
				return marks;
			}
			
			return marks;
			
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return null;
		} finally {
			pm.close();
		}
	}
}
